package cn.ljy.authority.web.controller.backstage;

import cn.ljy.authority.service.TokenService;
import cn.ljy.common.model.result.ResponseData;
import com.google.code.kaptcha.Producer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 处理后台登录、注销、验证码
 */
@Api(tags = "后台入口")
@RestController
@Slf4j
@Validated //加了后@NoNull之类的注解才能生效，如果只是@valid注解则不需要加上
@RequestMapping(value = "/api/backstage")
public class BackstageController extends BaseController{

    @Autowired
    private Producer producer;//验证码类
    @Autowired
    private TokenService tokenService;

    @ApiOperation(value = "获取验证码")
    @GetMapping("/verifyCode")
    public ResponseData getVerifyCode(String token) throws Exception{
        //获取验证码
        return ResponseData.success(tokenService.getVerifyCode());
    }
}
